import 'package:flutter/material.dart';
import './Products.dart';
import 'package:scoped_model/scoped_model.dart';
import '../../ScopedModels/ScopedProduct.dart';
// import './Product_Admin.dart';

class ProductPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print('[Products Widget] build');
    // TODO: implement build
    return Scaffold(
      drawer: Drawer(
          child: Column(
        children: <Widget>[
          AppBar(
            automaticallyImplyLeading: false,
            title: Text('Choose'),
          ),
          ListTile(
            title: Text('Manager Product'),
            onTap: () {
              //跳转到 '/'路由
              Navigator.pushReplacementNamed(context, '/admin');
            },
          )
        ],
      )),
      appBar: AppBar(
        title: Text("Widget基础练习"),
        actions: <Widget>[
          ScopedModelDescendant<ScopedProduct>(builder:
              (BuildContext context, Widget child, ScopedProduct model) {
            return IconButton(
                icon: Icon(model.showFavorite
                    ? Icons.favorite
                    : Icons.favorite_border),
                onPressed: () {
                  model.showFavoriteProduct();
                });
          })
        ],
      ),
      body: Products(),
    );
  }
}
